home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
madtrb9.arc
/
FRACTAL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-12-15
|
2KB
|
102 lines
PROGRAM Fractal;
{ This program produces fractal images on the IBM PC hi-res graphics screen }
{ according to your input specifications. See the September 1984 issue of }
{ Byte magazine for details on fractals and this program. }
{ Writen for Turbo Pascal v2.0. The 8087 version of Turbo Pascal should }
{ be used in order to achieve real time updating. }
{ The program uses the external procedure POINT.INV and CLS.INV. Both of }
{ these must be resident on the default disk in order to compile the prgm. }
{ Adapted by Jeff Firestone; May 23, 1984. HAL-PC Pascal SIG. }
{ Original Source: Greg Turk's program in Byte, Sept. 1984, p. 172. }
CONST
cx = 300.0;
cy = 98.0;
VAR
i : INTEGER;
y,x,t,s,lx,ly,tx,ty,sc : REAL;
KeyBufPointer : INTEGER;
PROCEDURE cls; EXTERNAL 'Cls.inv';
PROCEDURE Dot(a,b,c:INTEGER); EXTERNAL 'Point.inv';
PROCEDURE InitVars;
BEGIN
RANDOMIZE;
y:= 0;
x:= 0.50001;
END;
PROCEDURE GetValues;
BEGIN
cls;
CLRSCR;
WRITELN('This program produces fractal images according to the following parameters.');
WRITELN;WRITELN;
WRITE('What is Lambda X (0 to 3) : ');
READLN(lx);
WRITE('What is Lambda Y (0 or 1) : ');
READLN(ly);
s:= SQR(lx) + SQR(ly);
lx:= 4 * lx / s;
ly:= -4 * ly / s;
WRITE('What is Scale (2 to 10) : ');
READLN(sc);
sc:= 2 * cx / sc;
KeyBufPointer:= MEMW[$0040:$001A];
END;
FUNCTION KeyWasPressed : BOOLEAN; {doesn't work with turbo 3.+}
BEGIN
IF KeyBufPointer <> MEMW[$0040:$001A]
THEN
KeyWasPressed:= TRUE
ELSE
KeyWasPressed:= FALSE;
END;
PROCEDURE XYfunction;
BEGIN
tx:= x;
ty:= y;
x:= (tx * lx) - (ty * ly);
y:= (tx * ly) + (ty * lx);
x:= 1 - x;
t:= y;
s:= SQRT( SQR(x) + SQR(y) );
y:= SQRT( abs(-x + s) / 2 );
x:= SQRT( ( x + s) / 2 );
IF (t < 0) THEN x:= -x;
IF RANDOM < 0.5 THEN
BEGIN
x:= -x;
y:= -y;
END;
x:= (1 - x) / 2;
y:= y / 2;
END;
BEGIN
InitVars;
GetValues;
HIRES;
hirescolor(7);
FOR i:= 1 TO 10 DO XYfunction;
REPEAT
dot(ROUND( (2 * sc * (x - 0.5)) + cx), ROUND(cy - (sc * y)), 1);
XYfunction;
UNTIL Keypressed {KeyWasPressed}; {Use Keypressed with turbo 3.+ and}
END. {KeyWasPressed function for turbo 2.0}